package com.sunfeng.netty.atguigu.bytebase;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import lombok.extern.slf4j.Slf4j;

import java.nio.charset.StandardCharsets;

/**
 * @author 孙峰
 * @Description: TODO
 * @date 2020/12/11 14:50
 */
@Slf4j
public class Demo02 {
    public static void main(String[] args) {
        ByteBuf byteBuf = Unpooled.copiedBuffer("Netty in Action rocks!", StandardCharsets.UTF_8);
        log.info(byteBuf.getByte(0) + "");
        ByteBuf slice = byteBuf.copy(0, 15);

        System.out.println(slice.toString(StandardCharsets.UTF_8));
        byteBuf.setByte(0,(byte)'J');
        log.info(byteBuf.getByte(0) + "");


        log.info(slice.getByte(0) + "");
        System.out.println("说明原先的副本没有发生改变");
    }
}
